﻿
$.MGJ.CodeBatch = [];

(function () {
    var _this = $.MGJ.CodeBatch;
    $.extend($.MGJ.CodeBatch, {
        //编辑批次
        Dialog_EditBatchObj: null,
        Dialog_EditBatch: function (obj) {
            var BID = $(obj).attr("BID");
            var eid = $(obj).attr("Eid");
            this.Dialog_EditBatchObj = $.L.dialog({
                url: ACTION_URL("EditBatch", "CodeManage") + "?BID=" + BID + "&eid=" + eid,
                title: "编辑批次",
                width: 800,
                height: "auto",
                buttons: {
                    //"button_save": {
                    //    type: 'primary',
                    //    text: '保存',
                    //    click: function () {
                    //        var bootstrapValidator = $("#form-batch").data('bootstrapValidator').validate();//触发全部验证
                    //        if (bootstrapValidator.isValid()) {
                    //            //var submitData = JSON.stringify($("#form-batch").serializeObject())

                    //            //    uploader.options.formData = { "submitData": submitData };
                    //            //    uploader.upload();
                    //            _this.Ajax_CodeBatchEdit();
                    //            $(".btn-primary").attr("disabled", true);
                    //        } else {
                    //            $.L.msgError("请检查数据格式！");
                    //     }
                    //   }
                    //},
                    "button_cancel": {
                        type: 'default',
                        text: '取消',
                        click: 'MODALMISS'
                    }
                }
            });
        },
    });
})(jQuery);
(function () {
    var _index = 1;
    var _this = $.MGJ.CodeBatch;
    $.extend($.MGJ.CodeBatch, {
        //多条件查询
        Ajax_CodeBatchPageList: function (pageIndex) {
            _index = pageIndex;
            window.SearchKey = removeSpace($("#Batch").val());
            $.L.ajaxHandle({
                url: ACTION_URL("CodeBatchPageList", "CodeManage") + "?pageindex=" + pageIndex,
                data: $("#SearchForm").serialize(),
                success: function (response) {
                    $("#CodeBatchTable").L_bindingDataList(response);
                    $("#CodeBatchTable_left").L_bindingDataList(response);
                    $("#CodeBatchTable_right").L_bindingDataList(response);
                }
            });
        },
        Ajax_CodeBatchEdit: function () {
            $.L.ajaxHandle({
                url: ACTION_URL("BatchEditSave", "CodeManage"),
                data: $("#form-batch").serialize(),
                success: function (response) {
                    if (response > 0) {
                        _this.Dialog_EditBatchObj.close();
                        $.L.msgSuccess("操作成功！");
                        _this.Ajax_CodeBatchPageList(_index);
                    }
                }
            });
        },

        Ajax_ViewFlag: function (obj) {
            return obj == 0 ? "禁用" : "启用";
        },

       
        Ajax_hander: function (obj) {
            var temp = obj.split(",");
            var result = "";
            for (i = 0; i < temp.length ; i++) {
                if (temp[i] == 1) {
                    result += " 防伪码 ";
                } else if (temp[i] == 2) {
                    result += " 管理码 ";
                } else if (temp[i] == 3) {
                    result += " 积分码 ";
                }
            }
            return result;
        },
        Ajax_InitStatu: function (obj) {
            return obj == 0 ? "待生码" : "已成功";
        },
        Ajax_DelCodeBatch: function (obj) {
            $.L.msgConfirm("确认删除该记录?", function () {
                var id = $(obj).attr("CID");
                $.L.ajaxHandle({
                    url: ACTION_URL("DelCodeBatch", "CodeManage") + "?id=" + id,
                    data: { id: id },
                    success: function (response) {
                        if (response > 0) {
                            $.L.msgSuccess("操作成功！");
                            _this.Ajax_CodeBatchPageList(_index);
                        }
                        else {
                            $.L.msgError("该批次暂不允许被删除！");
                        }
                    }
                });
            })
        },
        //Ajax_BatchEditSave: function (data)
        //{
        //    $.L.ajaxHandle({                                            
        //        url: ACTION_URL("BatchEditSave", "CodeManage") + "?submitData=" + data,
        //             success: function (response) {
        //                 if (response > 0) {
        //                  _this.Dialog_EditBatchObj.close();
        //                $.L.msgSuccess("操作成功！");
        //                _this.Ajax_CodeBatchPageList(_index);
                      
        //            }
        //        }
        //    });
        //}
    });

})(jQuery);
(function () {
    var _this = $.MGJ.CodeBatch;
    $.extend($.MGJ.CodeBatch, {
        ConditionModel: {
            pageIndex: 1,
            pageSize: 10,
        },
    });
})(jQuery);
